export const focus = {
  inserted(el, binding, vnode, oldVnode) {
    console.log('vnode>>>>>>>>>>>>>>>>>', vnode, 'value', binding.value)
    if (binding.value) {
      el.focus()
    } else {
      el.blur()
    }
  },
  componentUpdated(el, binding) {
    if (binding.modifiers.lazy) {
      if (Boolean(binding.value) === Boolean(binding.oldValue)) {
        return
      }
    }

    if (binding.value) {
      el.focus()
    } else {
      el.blur()
    }
  }
}

export const mixin = {
  directives: {
    focus: focus
  }
}
